public class matrix
 {

	public static int[] GenerateRandArray(int size) {
		int[] rand = new int[size];
		for(int i=0;i<rand.length;i++) {
		rand[i] = (int) (Math.random() * 100);
	}
	return rand;
	}

	public static void printIntArray(int[] a) {
		for(int i=0;i<a.length;i++)
		System.out.println(" " + a[i]);
	}

	public static int[][] GenerMultiArray(int row, int col) {
		int[][] a1 = new int[row][col];
			for(int i=0;i<a1.length;i++)  {
				for(int j=0;j<a1[i].length;j++) {
				a1[i][j] = (int) (Math.random() * 100);
				}
		
			}
		return a1;
}

	public static void printMatrix(int[][] mat)
	{
	int i,j;
	for(i=0;i<mat.length;i++)
	{
		for(j=0;j<mat[i].length;j++)
		{
			System.out.print(mat[i][j] + "  ");
		}
		System.out.println(" ");
	}
	}

	public static int[][] addMat(int[][] mat1, int[][] mat2)
	{
		int[][] addM = new int[mat1.length][mat1[0].length];
			for(int i=0;i<mat1.length;i++)
			{
			for(int j=0;j<mat1[0].length;j++)
			{
				addM[i][j] = mat1[i][j] + mat2[i][j];
					
			}

		}
	return addM;
	}
	
	public static int[][] mulMat(int[][] mat1,int[][] mat2)
	{
		int[][] mulM = new int[mat1.length][mat2[0].length];
		int sum=0;
			for(int i=0;i<mat1.length;i++)
				for(int j=0;j<mat2[0].length;j++)
					for(int k=0;k<mat2.length;k++)
						{
							mulM[i][j] = mulM[i][j] + (mat1[i][k] * mat2[k][j]);
						}

					return mulM;
	}

	public static long sumMatrix(int[][] matrix)
	{
		
		long sum = 0;
		for(int i=0;i<matrix.length;i++) 
			for(int j=0;j<matrix[i].length;j++)
					sum = sum + matrix[i][j];
			
		return sum;
	}

	
	public static int[] sumRow(int[][] matrix)
	{
		
		int sum[] = new int[matrix.length];
		for(int i=0;i<matrix.length;i++) 
			for(int j=0;j<matrix[i].length;j++)
					sum[i] = sum[i] + matrix[i][j];
			
		return sum;
	}

	
public static int[] sumCol(int[][] matrix)
	{
		
		int sum[] = new int[matrix[0].length];
		for(int i=0;i<matrix.length;i++) 
			for(int j=0;j<matrix[i].length;j++)
					sum[j] = sum[j] + matrix[i][j];
			
		return sum;   
	
	}
	
	
	public static void bubbleSort(int[] matrix)
	{	
		for(int i = 0; i < matrix.length; i++) 
			for(int j = i+1 ; j < matrix.length;j++)
					if(matrix[i]>matrix[j])
					{
						int temp = matrix[i];
						matrix[i] = matrix[j];
						matrix[j] = temp;
					}
	}
	
	public static void selectionSort(int[] matrix)
	{
		int pos = -1;		
		for(int i = 0; i < matrix.length; i++)
		{
			pos = i;
			for(int j = i+1 ;j < matrix.length; j++)
				if(matrix[j]<matrix[pos])
					pos = j;				
			int temp = matrix[pos];
				matrix[pos] = matrix[i];
				matrix[i] = temp;
		}
	}
	
}